 /*
  * Copyright (c) 2021, 2023, yishun.cn All rights reserved.
  *
  */
 package cn.shun.aop;

 import lombok.extern.slf4j.Slf4j;
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.*;
 import org.springframework.stereotype.Component;

 /**
  * <p>Project: sboot_2023-cn.shun.aop-MyAop
  * <p>Powered by yishun On 2023-04-13 21:03:44
  *
  * @author yishun [2465734101@qq.com]
  * @version 1.0
  * @since 17
  */
 //@Component
 //@Aspect
 @Slf4j
 public class MyAop {

     /**
      * 切入点
      */
     @Pointcut("execution(* cn.shun..*(..))")
     public void point() {

     }

     @Before("point()")
     public void before() {
         log.debug("前置通知");
     }

     @After("point()")
     public void after() {
         log.debug("后置通知");
     }

     @Around("point()")
     public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
         log.debug("环绕前");
         Object value = joinPoint.proceed();
         log.debug("环绕后");
         return value;
     }

     @AfterReturning(value = "point()", returning = "a")
     public void afterReturning(Object a) {
         log.debug("正常返回结果:{}", a);
     }

     @AfterThrowing("point()")
     public void afterThrowing() {
         log.debug("目标方法抛出异常");
     }
 }
